package banking.reports;

import banking.*;
/**
 * 描述：客户报告
 * */
public class CustomerReport {
    public static void main(String[] args) {
        Bank bank = Bank.getBank();
        CustomerReport report = new CustomerReport();
        report.genReport(bank);
        report.genReport(Bank.getBanking());
        report.genReport(Bank.getBank());
    }

    private void genReport(Bank bank) {
        System.out.println("\nCustomer Report");
    }
    // generateReport
    public void generateReport() {
        Bank bank = Bank.getBank();
        System.out.println("\t\t\tCUSTOMERS REPORT");
        System.out.println("\t\t\t================");
        int numOfCustomers = bank.getNumOfCustomers();
        for (int i = 0; i < numOfCustomers; i++) {
            Customer customer = bank.getCustomer(i);
            System.out.println("Customer : " + customer.getLastName() + ", " + customer.getFirstName());
//            int numOfAccounts = customer.getNumOfAccounts();
//            Savings Account:current balance is $500.00
//            Checking Account:current balance is $200.00
            for (int j = 0; j < customer.getNumOfAccounts(); j++) {
                Account account = customer.getAccount(j);
                String account_type = account instanceof SavingsAccount ? "Savings Account" : "Checking Account";
                System.out.println("\t" + account_type + ":current balance is " + account.getBalance());
            }
        }
    }
}
